#! /usr/bin/env/python3
# coding:UTF-8
'''
    名称：掷骰子
    作者：王楠
    版本: 1.0
    日期：2020/03/01
    功能：掷一个骰子
'''
import random


class Dice():
    def __init__(self):
        pass

    def roll_dice(self):
        num = random.randint(1, 6)
        return num


def dice_main():
    roll_times = 1000      # 投掷次数
    dice1 = Dice()
    result_list = [0] * 6
    for i in range(roll_times):
        num = dice1.roll_dice()
        for x in range(1, 7):
            if num == x:
                result_list[x - 1] += 1
    print(result_list)
    for i, result in enumerate(result_list):
        print('总共投掷了{}，{}出现了{}次,频率是{}%'.format(
            roll_times, i + 1, result,
            result / roll_times * 100))


if __name__ == '__main__':
    dice_main()
